﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Chinaer.Model.Common;
using Chinaer.Core.Helper;

namespace Chinaer.Bll
{
    public class EmployeeLoginDetail : Repository, IBll.IEmployeeLoginDetail
    {
        private Chinaer.IDao.IEmployeeLoginDetailDAO employeeLoginDetailDAO = new Chinaer.Dao.EmployeeLoginDetailDAO();
        public JsonResult Add(DTO.EmployeeLoginDetailDTO t)
        {
            if (t.CheckIsNull().Success == false)
            {
                return t.CheckIsNull();
            }
            JsonResult jsonResult = new JsonResult();
            Model.Entities.Model_EmployeeLoginDetail model_EmployeeLoginDetail = new Model.Entities.Model_EmployeeLoginDetail();
            Chinaer.Core.Helper.DTOtoEntityObjectHelper.Instance.DTOtoEntityObject(t, model_EmployeeLoginDetail);
            if (string.IsNullOrEmpty(model_EmployeeLoginDetail.ID) || model_EmployeeLoginDetail.ID.Trim() == "")
            {
                model_EmployeeLoginDetail.ID = Chinaer.Core.Helper.GenerateIDHelper.GenerateID();
            }
            jsonResult.Success = employeeLoginDetailDAO.Add(model_EmployeeLoginDetail);
            return jsonResult;
        }

        public JsonResult Delete(DTO.EmployeeLoginDetailDTO t)
        {
            if (t.CheckIsNull().Success == false)
            {
                return t.CheckIsNull();
            }
            JsonResult jsonResult = new JsonResult();
            Model.Entities.Model_EmployeeLoginDetail model_EmployeeLoginDetail = new Model.Entities.Model_EmployeeLoginDetail();
            Chinaer.Core.Helper.DTOtoEntityObjectHelper.Instance.DTOtoEntityObject(t, model_EmployeeLoginDetail);
            jsonResult.Success = employeeLoginDetailDAO.Delete(model_EmployeeLoginDetail);
            return jsonResult;
        }

        public JsonResult Delete(string id)
        {           
            JsonResult jsonResult = new JsonResult();
            jsonResult.Success = employeeLoginDetailDAO.Delete(id);
            return jsonResult;
        }

        public JsonResult Update(DTO.EmployeeLoginDetailDTO t)
        {
            if (t.CheckIsNull().Success == false)
            {
                return t.CheckIsNull();
            }
            JsonResult jsonResult = new JsonResult();
            Model.Entities.Model_EmployeeLoginDetail model_EmployeeLoginDetail = new Model.Entities.Model_EmployeeLoginDetail();
            Chinaer.Core.Helper.DTOtoEntityObjectHelper.Instance.DTOtoEntityObject(t, model_EmployeeLoginDetail);
            jsonResult.Success = employeeLoginDetailDAO.Update(model_EmployeeLoginDetail);
            return jsonResult;
        }

        public DTO.EmployeeLoginDetailDTO GetByID(string id)
        {
            Model.Entities.Model_EmployeeLoginDetail model_EmployeeLoginDetail = employeeLoginDetailDAO.GetByID(id);
            DTO.EmployeeLoginDetailDTO employeeLoginDetailDTO = new DTO.EmployeeLoginDetailDTO();
            Chinaer.Core.Helper.DTOtoEntityObjectHelper.Instance.DTOtoEntityObject(model_EmployeeLoginDetail, employeeLoginDetailDTO);
            return employeeLoginDetailDTO;
        }
    }
}
